Received: from unknown (HELO mailhost.sosbbs.com) (204.186.168.100) by pop.onelist.com with SMTP; 5 Sep 1998 14:25:37 -0000
Received: from default (204.186.168.58) by mailhost.sosbbs.com (EMWAC SMTPRS 0.81) with SMTP id <B0000402644@mailhost.sosbbs.com>; Sat, 05 Sep 1998 10:26:24 -0400
Message-ID: <B0000402644@mailhost.sosbbs.com>
From: "Garfield Benjamin" <gbenjam@sosbbs.com>
To: <amos-list@onelist.com>
Date: Sat, 5 Sep 1998 10:47:28 -0400
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
Mailing-List: list amos-list@onelist.com; contact http://www.onelist.com
Delivered-To: mailing list amos-list@onelist.com
Precedence: bulk
Reply-to: amos-list@onelist.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Subject: [amos-list] REPOSTING OF JOYSTICK CODE...
Status: O
X-Status:
From: "Garfield Benjamin" <gbenjam@sosbbs.com>
ORIGINALLY SENT WEDNESDAY, NOW I AM RESENDING...
----------
>>> Hey! Look! At this Ne1 want a piece of joystick code...
>>Timer=0
>>For A=0 To 100000
>> J=Joy(1) : K=J-2 : P#=J/4.0 : P=P# : I=Sgn(J)
>> If P#=P Then X=Sgn(J-6)*I
>> If P=0 Then Y=I*(K+K+1)
>>Next
>>Print Timer
>> Hmm this seemed a bit too complicated, so I decided to check it out
>>(and I managed to kill 5mins at the same time ;)
>>Timer=0
>>For A=0 To 100000
>> X=0 : Y=0
>> If Jup(1) Then Y=-1
>> If Jdown(1) Then Y=1
>> If Jleft(1) Then X=-1
>> If Jright(1) Then X=1
>>Next
>>Print Timer
Well, I live for writing compact, optimized code...
THE OPTIMIZED WAY:
Timer=0
For REP=0 To 100000
X=Jleft(1)-Jright(1)
Y=Jup(1)-Jdown(1)
Next REP
Print Timer
Compiled with AMOS PRO Compiler and tested on a 14MHz NTSC
Amiga...
NO JOYSTICK MOVEMENT
First version: 779
Second version: 502
My version: 471
HOLDING DOWN ON JOYSTICK
First Version: 933
Second version: 511
My version: 476
Obviously, if tested on an accelerated Amiga the performance will be
greatly increased (ie. smaller times) and it is much shorter as well.